<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">











<!--

 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

--><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>log4cxx - Frequently Asked Technical Questions</title>
    <style type="text/css" media="all">
      @import url("./css/maven-base.css");
      @import url("./css/maven-theme.css");
      @import url("./css/site.css");
    </style>
    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
      </head>
  <body class="composite">
    <div id="banner">
                  <a href="http://logging.apache.org/" id="bannerLeft">
    
                                            <img src="images/ls-logo.jpg" alt="" />
    
            </a>
                    <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
          
  

  
    
  
  
    
            <div class="xleft">
        Last Published: 2008-03-31
                          |   
                <a href="http://www.apache.org/" class="externalLink">Apache</a>
                &gt;
      
                <a href="http://logging.apache.org/" class="externalLink">Logging Services</a>
                &gt;
      
          log4cxx
                        </div>
            <div class="xright">      
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
           
  

  
    
  
  
    
                   <h5>Get log4cxx</h5>
            <ul>
              
    <li class="none">
                    <a href="download.html">Download</a>
          </li>
              
    <li class="none">
                    <a href="changes-report.html">Changes</a>
          </li>
              
    <li class="none">
                    <a href="license.html">License</a>
          </li>
          </ul>
              <h5>About log4cxx</h5>
            <ul>
              
    <li class="none">
                    <a href="index.html">What is log4cxx?</a>
          </li>
              
    <li class="none">
                    <a href="apidocs/index.html">API Documentation</a>
          </li>
              
    <li class="none">
              <strong>FAQ</strong>
        </li>
          </ul>
              <h5>Community</h5>
            <ul>
              
    <li class="none">
                    <a href="mail-lists.html">Mailing Lists</a>
          </li>
              
    <li class="none">
                    <a href="issue-tracking.html">Issue Tracking</a>
          </li>
              
    <li class="none">
                    <a href="http://wiki.apache.org/logging-log4cxx" class="externalLink">Wiki</a>
          </li>
          </ul>
              <h5>Development</h5>
            <ul>
              
    <li class="none">
                    <a href="source-repository.html">Repository</a>
          </li>
              
          
              
      
            
      
            
      
            
      
            
      
              
        <li class="expanded">
                    <a href="">Building</a>
                  <ul>
                  
    <li class="none">
                    <a href="building/autotools.html">autotools</a>
          </li>
                  
    <li class="none">
                    <a href="building/ant.html">Apache Ant</a>
          </li>
                  
    <li class="none">
                    <a href="building/maven.html">Apache Maven 2</a>
          </li>
                  
    <li class="none">
                    <a href="building/vstudio.html">Microsoft Visual Studio</a>
          </li>
                  
    <li class="none">
                    <a href="building/xcode.html">Apple Xcode</a>
          </li>
              </ul>
        </li>
          </ul>
              <h5>Apache</h5>
            <ul>
              
    <li class="none">
                    <a href="http://www.apache.org" class="externalLink">Home</a>
          </li>
              
    <li class="none">
                    <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsorship</a>
          </li>
              
    <li class="none">
                    <a href="http://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a>
          </li>
              
    <li class="none">
                    <a href="http://www.apachecon.com" class="externalLink">Conferences</a>
          </li>
          </ul>
                                           <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
          </a>
                       
  

  
    
  
  
    
        </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
        <div class="section"><h2><a name="top">Frequently Asked Technical Questions</a>
</h2>
<ol type="1"><li><a href="#custom_levels">How do I add a custom level to Apache log4cxx?</a>
</li>
<li><a href="#msvc_crash">My application on Windows crashes on shutdown?</a>
</li>
<li><a href="#unicode">Does Apache log4cxx support Unicode?</a>
</li>
</ol>
</div>
<dl><dt><a name="custom_levels">How do I add a custom level to Apache log4cxx?</a>
</dt>
<dd>
      <p>This is a common topic for all the Apache logging frameworks and
      typically motivated to try to categorize events by functionality or
      audience.  An common request is to add an AUDIT level so that the
      user can configure AUDIT level messages to go to a specific appender.
      However, the logger name was designed explicitly to support
      routing of messages by topic or audience.  The common
      pattern of using classnames for logger names obscures the more
      general capability of logger name to represent the topic or audience 
      of the logging request.  The easiest approach to solve the underlying issue
      is to use a logger names like "AUDIT.com.example.MyPackage.MyClass"
      that allow all AUDIT messages to be routed to a particular appender.
      If you attempted to use a level for that then you would lose
      the ability to distinguish between different significances within
      the audit messages.
     </p><table border="0"><tr><td align="right"><a href="#top">[top]</a>
</td></tr></table><hr />
</dd>
<dt><a name="msvc_crash">My application on Windows crashes on shutdown?</a>
</dt>
<dd>
      <p>Apache log4cxx API calls use C++ Standard Template Library string
      parameters.  If the caller is using a different instance or type of the
      C Runtime Library that log4cxx, then it is very likely that some memory
      that was originally allocated by log4cxx would be freed by the caller.
      If log4cxx and the caller are using different C RTL's, the program 
      will likely crash at the point.  Use "Multithread DLL" with release
      builds of log4cxx and "Multithread DLL Debug" with debug builds.
     </p><table border="0"><tr><td align="right"><a href="#top">[top]</a>
</td></tr></table><hr />
</dd>
<dt><a name="unicode">Does Apache log4cxx support Unicode?</a>
</dt>
<dd>
      <p>Yes.  Apache log4cxx exposes API methods in multiple string flavors
      const char*, std::string, wchar_t*, std::wstring, CFStringRef et al.
      const char* and std::string are interpreted according to the 
      current locale settings.  Applications should call setlocale(LC_ALL, "")
      on startup or the C RTL will assume US-ASCII.
      Before being processed internally, all these are converted to the
      LogString type which is one of several supported Unicode representations
      selected by the --with-logchar option.  When using methods that take LogString arguments,
      the LOG4CXX_STR() macro can be used to convert ASCII literals to 
      the current LogString type.  FileAppenders support an encoding 
      property which should be explicitly specified to "UTF-8" or "UTF-16"
      for XML files.
     </p><table border="0"><tr><td align="right"><a href="#top">[top]</a>
</td></tr></table></dd>
</dl>

      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">&#169;  
          2008
    
          Apache Software Foundation
          
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>
